package
{
	import net.hires.debug.Stats;
	import com.marsyang.display.*;
	import com.marsyang.events.EffectEvent;
	import com.marsyang.model.ModelLocator;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.display.StageScaleMode;
	
	
	[SWF(backgroundColor="0x000000", frameRate="30")]
	
	public class Plane3DEffect extends Sprite
	{
		private var stage3d:Stage3D;
		private var menubar:MenuBar;
		private var stats:Stats;
		
		public var model:ModelLocator = ModelLocator.getInstance();
		
		public function Plane3DEffect()
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.showDefaultContextMenu = false;
			addEventListeners();
			addDisplayObjects();
		}
		private function addEventListeners():void
		{
			stage.addEventListener(EffectEvent.GO_HOME, effectEventHandler);
			stage.addEventListener(EffectEvent.GO_CONTENT, effectEventHandler);
		}
		private function addDisplayObjects():void
		{
			stage3d = new Stage3D();
			addChild(stage3d);
			menubar = new MenuBar();
			addChild(menubar);
			stats = new Stats();
			addChild(stats);
		}
		private function effectEventHandler(e:EffectEvent):void
		{
			switch(e.type) 
			{
				case EffectEvent.GO_HOME:
					model.renderType = "IN";
					break;
				case EffectEvent.GO_CONTENT:
					model.renderType = "OUT";
					if(model.previousMenu != 0)
					{
						stage3d.renderRota();
					}
					break;
			}
		}
	}
}